Performs processing on the IRecognitionForm on the page number and fields provided as parameters.
public void Recognize(
int recognitionPageNumber,
ITemplateForm templateForm,
int templatePageNumber,
IEnumerable<Field> fields
)
recognitionPageNumber
Integer that represents the page number in the recognition form's Pages collection.
templateForm
The template form object.
templatePageNumber
Integer that represents the page number in the template form Pages collection.
fields
A generic collection of Field to be processed in this IRecognitionForm.
The results of recognizing the fields on this filled-in form can be accessed from the Field.Result property.
When the Recognize method is invoked, fields provided as a parameter are aligned and processed in the filled-in form.
Note
The following example is a snippet of a larger example project. To run the larger example project, follow the work flow laid out in the OMREngine example. You can also download the complete Visual Studio 2017 project.
using Leadtools;
using Leadtools.Barcode;
using Leadtools.Codecs;
using Leadtools.Forms.Processing.Omr;
using Leadtools.Forms.Processing.Omr.Fields;
using Leadtools.Ocr;
public static List<IRecognitionForm> RecognizeMultipleForms(ITemplateForm template, OmrEngine engine)
{
string[] inputs = Directory.GetFiles(Path.Combine(LEAD_VARS.ImagesDir, @"Forms\OMR Processing\Exam\filled\"));
List<IRecognitionForm> recognizedForms = new List<IRecognitionForm>();
// each filled form is recognized separately
for (int i = 0; i < inputs.Length; i++)
{
string fileToRecognize = inputs[i];
IRecognitionForm formToRecognize = engine.CreateRecognitionForm();
formToRecognize.Name = string.Format("Exam {0}", i + 1);
using (RasterImage fileToRecognizeImage = engine.EnginesObject.RasterCodecs.Load(fileToRecognize))
{
for (int j = 0; j < fileToRecognizeImage.PageCount; j++)
{
fileToRecognizeImage.Page = j + 1;
formToRecognize.Pages.AddPage(fileToRecognizeImage);
}
formToRecognize.Recognize(template);
}
for (int j = 0; j < formToRecognize.Pages[0].Fields.Count; j++)
{
OmrField field = formToRecognize.Pages[0].Fields[j] as OmrField;
if (field != null)
{
OmrFieldResult omrFieldResult = (OmrFieldResult)field.Result;
Console.Write(omrFieldResult.Text + "\t");
}
}
Console.WriteLine();
recognizedForms.Add(formToRecognize);
}
return recognizedForms;
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}